mouse_down

This function checks if a particular mouse button is currently being held down.

bool mouse_down(int button)

Parameters:
button
A mouse button number from 0 to 7 (see remarks).

Return value:
true if the button is held down, false if it is not or if an error occurs.

Remarks:
The difference between mouse_down and mouse_pressed is that mouse_pressed will only return true when the user first pushes down the button, while mouse_down will continue returning true until the button is released again.

The button number can be between 0 and 7, however not many mouse devices will have as many as 8 buttons. The numbers correspond to the following buttons:

Example:
// Play a looping sound while the left mouse button is held down, and use escape to close.

void main()
{
show_game_window("Test Game");
sound horn;
horn.load("horn.wav");
if(horn.active==false)
{
alert("Error", "The sound could not be loaded.");
exit();
}
while(true)
{
mouse_update();
if(mouse_down(0))
{
if(horn.playing==false)
{
horn.play_looped();
}
}
else
{
if(horn.playing==true)
{
horn.stop();
}
}
if(key_pressed(KEY_ESCAPE))
{
exit();
}
wait(5);
}
}